home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-19 | 2.9 KB | 79 lines | [TEXT/CWIE] |
- (*
- Problem 05 - Database
-
- type
- StringsHandle = Handle; // Sequence of Pascal Strings packed together
- DatabaseHandle = Handle; // Must be a real handle
-
- procedure DatabaseInit( var database: Handle; field_count: UInt32 );
- procedure DatabaseAddEntry( database: Handle; entry: StringsHandle );
- procedure DatabaseFindEntry( database: Handle; field: UInt32; const match:
- Str255; var entry: StringsHandle );
- procedure DatabaseDeleteEntry( database: Handle; field: UInt32; const match:
- Str255 );
- function DatabaseCount( database: Handle ): UInt32;
- procedure DatabaseGetIndEntry( database: Handle; index: UInt32; var entry:
- StringsHandle );
-
- Your task is to write a set of routines to maintain a database.
-
- DatabaseInit creates a new, empty database ready to accept records with
- field_count string fields. The database is stored in the database Handle.
-
- DatabaseAddEntry adds an entry (which is a Handle to field_count pascal strings
- packed together conceptually numbered 1 to field_count)
-
- DatabaseFindEntry finds an entry whose field (between 1 and field_count) string
- is exactly equal to match. The entry is returned in a newly created handle
- (which will be disposed of using DisposeHandle). Return nil if no match is
- found. If more than one entry matches, you must return the earliest added
- entry.
-
- DatabaseDeleteEntry finds the entry that DatabaseFindEntry would find, and if
- found removes it from the database.
-
- DatabaseCount returns the number of entries in the database.
-
- DatabaseGetIndEntry returns the entries in the Database in the order they were
- entered, 1 for the earliest entered, DatabaseCount the last entered.
-
- All the database information must be stored in the real Mac memory manager
- handle - it will be disposed with DisposeHandle and that must release all
- memory, so do not store any extra information outside the handle. Also, you
- must be able to deal with having multiple databases instantiated
- simultaneously.
-
- You will not be given invalid parameters so you don't need to handle error
- checking, and there will be plenty of memory.
-
- All strings are case sensitive (ie, treated as eight bit binary data).
- *)
-
- unit Solution;
-
- interface
-
- // Do not modify the interface
-
- uses
- Types, Files;
-
- type
- StringsHandle = Handle; // Sequence of Pascal Strings packed together
- DatabaseHandle = Handle; // Must be a real handle
-
- procedure DatabaseInit( var database: Handle; field_count: UInt32 );
- procedure DatabaseAddEntry( database: Handle; entry: StringsHandle );
- procedure DatabaseFindEntry( database: Handle; field: UInt32; const match: Str255; var entry: StringsHandle );
- procedure DatabaseDeleteEntry( database: Handle; field: UInt32; const match: Str255 );
- function DatabaseCount( database: Handle ): UInt32;
- procedure DatabaseGetIndEntry( database: Handle; index: UInt32; var entry: StringsHandle );
-
- implementation
-
- // Fill in your solution and then submit this folder
-
- // Team Name: FILL IN YOUR TEAM NAME!
-
- end.
-